// var app = getApp();

const systemData = wx.getSystemInfoSync();

function getFitHeight() {
  var reg = /android/i;
  if (reg.test(systemData.system) && systemData.pixelRatio == 3) {

    return systemData.windowHeight - 25 ;

  } else {
    return systemData.windowHeight;
  }
}

const fitHeight = getFitHeight() -10;

const addInfo = {
  id: 1,
  iconPath: '/resources/images/addinfo.png',
  position: {
    left: systemData.windowWidth - 67 - 17,
    top: fitHeight - 67 - 30,
    width: 67,
    height: 67
  },
  clickable: true
}

const myorderIcon = {
  id: 6,
  iconPath: '/resources/images/addinfo-atv.png',
  position: {
    left: systemData.windowWidth - 67 - 17,
    top: fitHeight - 67 - 30,
    width: 67,
    height: 67
  },
  clickable: true
}

const leftPartHeight = 65

const goMe = {
  id: 2,
  iconPath: '/resources/images/me.png',
  position: {
    left: 17,
    top: fitHeight - leftPartHeight - 55,
    width: 34,
    height: 34
  },
  clickable: true
}

const chuxing = {
  id: 3,
  iconPath: '/resources/images/switch/chuxing.png',
  position: {
    left: 17,
    top: fitHeight - leftPartHeight - 17,
    width: 44,
    height: 53
  },
  clickable: true
}

// const moren = {
//   id: 4,
//   iconPath: '/resources/images/switch/moren.png',
//   position: {
//     left: 61,
//     top: fitHeight - leftPartHeight - 17,
//     width: 44,
//     height: 53
//   },
//   clickable: true
// }

const wuzhangai = {
  id: 5,
  iconPath: '/resources/images/switch/wuzhangai.png',
  position: {
    left: 61,
    top: fitHeight - leftPartHeight - 17,
    width: 46,
    height: 53
  },
  clickable: true
}

const chuxing_act = Object.assign({}, chuxing, {
  iconPath: '/resources/images/switch/chuxing_act.png'
});

// const moren_act = Object.assign({}, moren, {
//   iconPath: '/resources/images/switch/moren_act.png'
// });

const wuzhangai_act = Object.assign({}, wuzhangai, {
  iconPath: '/resources/images/switch/wuzhangai_act.png'
});

const bar_chuxing_act = [chuxing_act,  wuzhangai]
// const bar_moren_act = [chuxing, moren_act, wuzhangai]

const bar_wuzhangai_act = [chuxing,  wuzhangai_act]

var mapHeight = 0;

function getFitHeight() {
  var systemData = wx.getSystemInfoSync();
  var reg = /android/i;
  if (reg.test(systemData.system) && systemData.pixelRatio == 3) {
    return systemData.windowHeight - 25;

  } else {
    return systemData.windowHeight;
  }
}

mapHeight = getFitHeight()

//当没有电话信息的时候,需要给地图增加一个高度
const extractHeight = 28 

const markerTypes = {
  order: {
    iconPath: "/resources/images/p.png",
    width: 33,
    height: 44
  },
  order_act: {
    // iconPath: "/resources/images/p_act.png",
    width: 47,
    height: 57
  },
  freeBarrier: {
    width: 22,
    height: 27
  },
  freeBarrierAct: {
    width: 26,
    height: 32
  }
}

const freeBarrierIconPaths = {
  canlian: {
    typeId: 1,
    name: '残联机构',
    internal_name: 'institution',
    path: '/resources/images/free/canlian.png'
  },
  gongce: {
    typeId: 2,
    name: '公厕',
    internal_name: 'toilet',
    path: '/resources/images/free/gongce.png'
  },
  gouwu: {
    typeId: 3,
    name: '商场购物',
    internal_name: 'mall',
    path: '/resources/images/free/gouwu.png'
  },
  jiudian: {
    typeId: 4,
    name: '宾馆酒店',
    internal_name: 'hotel',
    path: '/resources/images/free/jiudian.png'
  },
  keyun: {
    typeId: 5,
    name: '客运站',
    internal_name: 'station',
    path: '/resources/images/free/keyun.png'
  },
  lvyou: {
    typeId: 6,
    name: '旅游景点',
    internal_name: 'viewspot',
    path: '/resources/images/free/lvyou.png'
  },
  tongxin: {
    typeId: 7,
    name: '通讯',
    internal_name: 'communication',
    path: '/resources/images/free/tongxin.png'
  },
  wenyu: {
    typeId: 8,
    name: '文化娱乐',
    internal_name: 'entertainment',
    path: '/resources/images/free/wenyu.png'
  },
  yaofang: {
    typeId: 9,
    name: '药房',
    internal_name: 'pharmacy',
    path: '/resources/images/free/yaofang.png'
  },
  yinhang: {
    typeId: 10,
    name: '银行',
    internal_name: 'bank',
    path: '/resources/images/free/yinhang.png'
  },
  yiyuan: {
    typeId: 11,
    name: '医院',
    internal_name: 'hospital',
    path: '/resources/images/free/yiyuan.png'
  },
  youju: {
    typeId: 12,
    name: '邮局',
    internal_name: 'postoffice',
    path: '/resources/images/free/youju.png'
  },
  yinshi: {
    typeId: 13,
    name: '饮食餐厅',
    internal_name: 'restaurant',
    path: '/resources/images/free/yinshi.png'
  },

}



const mapType = {
  showDefault: 'default',
  showOrders: 'showOrders',
  showBarrierFree: 'showBarrierFree'
}

const ctrlsType = {
  addInfo: 1,
  moveToMe: 2,
  showOrders: 3,
  showDefault: 4,
  showBarrierFree: 5,
  showMyOrder: 6
}

const ordersHeight = 130;
const freeBarrierHeight = 148;


function getHomeCtrlsByMapType(mapTypeName,isHasMyOrder) {

  var defaultIcons = [addInfo, goMe];
  // var mapType = 'showOrders'
  if(isHasMyOrder){
    defaultIcons = [myorderIcon,goMe]
  }
  var result = [];

  switch (mapTypeName) {
    case mapType.showBarrierFree:

      result = defaultIcons.concat(bar_wuzhangai_act)
      break;
    case mapType.showOrders:

      result = defaultIcons.concat(bar_chuxing_act)

      break;
    
  }

  return result;
}

const wsType = {
  freeBarrier: 'freeBarrier',
  allOrders: 'allOrders'
}

const apiUrl = 'https://https.bp1010.cn/api'

const wsUrl = 'wss://https.bp1010.cn/wss'

const imgUrl = 'http://img.waterdrop.bp1010.cn'

const lngRange = 0.01;
const latRange = 0.015;

const orderLngRange = 0.15;
const orderLatRange = 0.16;

const pageSize = 200 
const showBarrierFreeDefaultScale = 17;
const defaultScale = 16;

const successCode = 200;

const duration = 86400;

module.exports = {
  // homeCtrls: [addInfo, goMe, chuxing, moren, wuzhangai],
  homeCtrls: [addInfo, goMe, chuxing, wuzhangai],
  // myorderCtrls: [myorderIcon, goMe, chuxing, moren, wuzhangai],
  myorderCtrls: [myorderIcon, goMe, chuxing, wuzhangai],
  mapHeight: mapHeight,
  markerTypes: markerTypes,
  mapType: mapType,
  ordersHeight: ordersHeight,
  ctrlsType: ctrlsType,
  bar_chuxing_act: bar_chuxing_act,
  // bar_moren_act: bar_moren_act,
  bar_wuzhangai_act: bar_wuzhangai_act,
  getHomeCtrlsByMapType: getHomeCtrlsByMapType,
  freeBarrierIconPaths: freeBarrierIconPaths,
  freeBarrierHeight: freeBarrierHeight,
  apiUrl: apiUrl,
  wsUrl: wsUrl,
  imgUrl: imgUrl,
  lngRange: lngRange,
  latRange: latRange,
  pageSize: pageSize,
  showBarrierFreeDefaultScale: showBarrierFreeDefaultScale,
  defaultScale: defaultScale,
  successCode: successCode,
  myorderIcon: myorderIcon,
  wsType: wsType,
  duration: duration,
  orderLngRange:orderLngRange,
  orderLatRange:orderLatRange,
  extractHeight:extractHeight
}